{%  extends "myadmin/index.html"  %}

{%  block myadmin_index  %}
 <!-- 内容区域 -->
        <div class="tpl-content-wrapper">
            <div class="row-content am-cf">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title  am-cf">用户列表</div>


                            </div>
                            <div class="widget-body  am-fr">

                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                                    <div class="am-form-group">
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <button type="button" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> <a href="{% url 'myadmin_adduser' %}">新增</a></button>
                                                <button type="button" class="am-btn am-btn-default am-btn-warning"><span class="am-icon-archive"></span> 修改</button>
                                                <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-6 am-u-lg-3">
                                    <div class="am-form-group tpl-table-list-select">
                                        <select data-am-selected="{btnSize: 'sm'}">
              <option value="option1">所有类别</option>
              <option value="option2">用户</option>
              <option value="option3">性别</option>
            </select>
                                    </div>
                                </div>
                                <div class="am-u-sm-12 am-u-md-12 am-u-lg-3">
                                    <div class="am-input-group am-input-group-sm tpl-form-border-form cl-p">
                                        <input type="text" class="am-form-field ">
                                        <span class="am-input-group-btn">
            <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search" type="button"></button>
          </span>
                                    </div>
                                </div>



                                <div class="am-u-sm-12">
                                    <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " id="example-r">
                                        <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>用户名</th>
                                                <th>头像</th>
                                                <th>密码</th>
                                                <th>年龄</th>
                                                <th>性别</th>
                                                <th>手机号</th>
                                                <th>状态</th>
                                                <th>添加时间</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            {% for i in userinfo %}
                                            <tr class="gradeX">
                                                <td>{{ i.id }}</td>
                                                <td>{{ i.username }}</td>
                                                <td><img src="{{ i.head_url }}" width="50"></td>
                                                <td>{{ i.password }}</td>
                                                <td>{{ i.age }}</td>
                                                {% if i.sex == "1" %}
                                                <td>男</td>
                                                {% elif i.sex == "0" %}
                                                <td>女</td>
                                                {% else %}
                                                <td>未知</td>
                                                {% endif %}
                                                <td>{{ i.phone }}</td>

                                                <td>
                                                    <select style="background:blue" class="changes" uid="{{ i.id }}">
                                                        <option {% if i.status == 0 %}selected {% endif %} values="0">正常</option>
                                                        <option {% if i.status == 1 %}selected {% endif %} values="1">禁用</option>
                                                    </select>
                                                </td>
                                                <td>{{ i.addtime }}</td>
                                                
                                                <td>
                                                    <div class="tpl-table-black-operation">
                                                        <a href="{% url 'myadmin_edituser' %}?uid={{ i.id }}"><i class="am-icon-pencil"></i>编辑</a>
                                                        <a href="{% url 'myadmin_deluser' %}?uid={{ i.id }}" class="tpl-table-black-operation-del"><i class="am-icon-trash"></i>删除</a>
                                                        <a href="javaScript:void(0)" class="changepwd" uid={{ i.id }} class="tpl-table-black-operation-del"><i class="am-icon-trash"></i>重置密码</a>
                                                    </div>
                                                </td>
                                                
                                            </tr>
                                            {% endfor %}
                                        </tbody>

                                        <script type="text/javascript">
                                            // 状态修改
                                            $('.changes').change(function(){
                                                var uid = $(this).attr('uid')
                                                var val = $(this).val()
                                                $.get('{% url "myadmin_changes" %}',{uid:uid,status:val},function(data){
                                                    alert(data.msg)
                                                },'json')
                                            })

                                            //密码重置
                                            $('.changepwd').click(function(){
                                                // 获uid
                                                var uid=$(this).attr('uid')
                                                console.log(uid)
                                                // 放ajax请求 重置密码
                                                $.get('{% url "myadmin_respwd" %}',{uid:uid},function(data){
                                                    alert(data.msg)
                                                },'json')
                                            })
                                        </script>

                                    </table>

                                    <!-- 分页 -->
                                    <div class="am-u-lg-12 am-cf">
                                        <div class="am-fr">
                                            <ul class="am-pagination tpl-pagination">
                                                <li><a
                                                    href="{% url 'myadmin_vipuser' %}?p=1&type={{request.GET.type}}&search={{request.GET.search}}">首页</a>
                                                </li>
                                                <li {% if page == 1 %}class="am-disabled" {% endif %}><a
                                                    href="{% url 'myadmin_vipuser' %}?p={{page|add:-1}}&type={{request.GET.type}}&search={{request.GET.search}}">?</a>
                                                </li>
                                                {% for i in prange %}
                                                <li {% if page == i %} class="am-active" {% endif %}><a
                                                    href="{% url 'myadmin_vipuser' %}?p={{i}}&type={{request.GET.type}}&search={{request.GET.search}}">{{i}}</a>
                                                </li>
                                                {% endfor %}
                                                <li {% if page == sumpage %}class="am-disabled" {% endif %}><a
                                                    href="{% url 'myadmin_vipuser' %}?p={{page|add:1}}&type={{request.GET.type}}&search={{request.GET.search}}">?</a>
                                                </li>
                                                <li><a
                                                    href="{% url 'myadmin_vipuser' %}?p={{sumpage}}&type={{request.GET.type}}&search={{request.GET.search}}">尾页</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </div>                                                    
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{%  endblock  %}

